package de.fhkl.gatav.ut.bubbles_0;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;

class Bubble {
	private float x, y, speed;
	
	private static final Paint bubblePaint = new Paint();
	static {
		bubblePaint.setStyle(Paint.Style.FILL);
		bubblePaint.setColor(Color.CYAN);
		bubblePaint.setAlpha(150);
		bubblePaint.setAntiAlias(true);
	}

	public static final int RADIUS = 10;
	public static final int MAX_SPEED = 10;
	public static final int MIN_SPEED = 1;

	public Bubble (float x, float y, float speed) {
		this.x = x;
		this.y = y;
		this.speed = Math.max(speed, MIN_SPEED);
	}

	public void draw(Canvas c) {
		c.drawOval(new RectF(x-RADIUS, y-RADIUS, x+RADIUS, y+RADIUS),
				   bubblePaint);
	}

	public void move() {
		y -= speed;
	}

	public boolean outOfRange() {
		return (y+RADIUS < 0);
	}
}